package com.gtm.repository;

import com.gtm.model.Topic;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.data.mongodb.repository.Query;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by 骆清波 on 2017/10/28.
 */
public interface TopicRepository extends MongoRepository<Topic, String> {

    @Query("{$and:[{$or:[{topicSrc:{$regex:?0}},{topicType:{$regex:?0}},{topicName:{$regex:?0}}]},{teacherId:?1}]}")
    Page<Topic> listOwnBySearchKey(String searchKey, Pageable pageRequest, String tid);

    List<Topic> findByTeacherNameLikeOrTeacherTelLike(String s, String s1);

    List<Topic> findByTeacherNameLikeOrTeacherTelLikeOrTopicNameLikeOrTopicSrcLikeOrTopicTypeLikeAndMarkedDelIs(String tname, String ttel, String tpname, String tpsrc, String tptype, boolean b);

    List<Topic> findByTeacherNameLikeOrTeacherTelLikeOrTopicNameLikeOrTopicSrcLikeOrTopicTypeLike(String searchKey, String searchKey1, String searchKey2, String searchKey3, String searchKey4);

    Topic findByIdAndMarkedDel(String tpid, Boolean flag1);

    void deleteByTeacherId(String tid);


    List<Topic> findByTeacherId(String tid);

    List<Topic> findByTeacherIdAndMarkedDel(String tid, Boolean aBoolean);

    List<Topic> findByIdAndMarkedDelAndTeacherId(String topicChose, boolean b, String tid);
}
